using System;
using UnityEngine;

[Serializable]
public class TTCameraBehaviourZoomToPlayer : TTCameraBehaviour
{
	public Vector3 initialPositionOffset;

	public float angle;

	public float horizontalDistance;

	public float height;

	public Vector3 lookAtOffset;

	private Vector3 posToAim;

	private Vector3 facePosition;

	public override void Start(Camera cam, TTCameraController camController, TTCameraOptions cameraOptions)
	{
		base.Start(cam, camController, cameraOptions);
		camera.transform.position = cameraOptions.player.transform.position + initialPositionOffset;
		posToAim = cameraOptions.player.transform.position;
		Transform transform = cameraOptions.player.transform.Search("HEAD");
		facePosition = ((!(transform != null)) ? Vector3.zero : transform.position);
		camera.transform.rotation = Quaternion.LookRotation(facePosition + lookAtOffset - camera.transform.position);
	}

	public override void Update()
	{
		Transform transform = cameraOptions.player.transform.Search("HEAD");
		facePosition = ((!(transform != null)) ? Vector3.zero : transform.position);
		Vector3 vector = new Vector3(Mathf.Sin(angle * ((float)Math.PI / 180f)) * horizontalDistance, height, Mathf.Cos(angle * ((float)Math.PI / 180f)) * horizontalDistance);
		camera.transform.position = Vector3.Lerp(camera.transform.position, posToAim + vector, RealTime.deltaTime * moveSpeed);
		Quaternion b = Quaternion.LookRotation(facePosition + lookAtOffset - camera.transform.position);
		camera.transform.rotation = Quaternion.Lerp(camera.transform.rotation, b, RealTime.deltaTime * rotationSpeed);
		camera.fieldOfView = fov;
	}
}
